package com.imooc.trading_system.controller;


import com.imooc.trading_system.service.OrderBaseService;
import com.imooc.trading_system.utils.JsonData;
import com.imooc.trading_system.vo.order.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Feng zhaoxi
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/api/order")
public class OrderBaseController {
    @Autowired
    private OrderBaseService orderBaseService;

    /**
     * 创建订单
     *
     * @param createOrderReqVO
     * @return
     */
    @PostMapping("create_order")
    public JsonData createOrder(@RequestBody CreateOrderReqVO createOrderReqVO) {
        return orderBaseService.createOrder(createOrderReqVO);
    }

    /**
     * 获取我的订单
     *
     * @return
     */
    @PostMapping("get_order")
    public JsonData getMyOrder(@RequestBody GetMyOrderReqVO getMyOrderReqVO) {
        return orderBaseService.getMyOrder(getMyOrderReqVO);
    }

    /**
     * 支付订单
     *
     * @param payReqVO
     * @return
     */
    @PostMapping("pay")
    public JsonData toPay(@RequestBody PayReqVO payReqVO) {
        return orderBaseService.toPay(payReqVO);
    }

    /**
     * 确认收货
     *
     * @param confirmReqVO
     * @return
     */
    @PostMapping("confirm")
    public JsonData confirm(@RequestBody ConfirmReqVO confirmReqVO) {
        return orderBaseService.confirm(confirmReqVO);
    }

    /**
     * 买家给卖家评价
     *
     * @param evaluationReqVO
     * @return
     */
    @PostMapping("evaluation")
    public JsonData evaluation(@RequestBody EvaluationReqVO evaluationReqVO) {
        return orderBaseService.evaluation(evaluationReqVO);
    }

    /**
     * 卖家发货
     *
     * @param deliverGoodsReqVO
     * @return
     */
    @PostMapping("deliver_goods")
    public JsonData deliverGoods(@RequestBody DeliverGoodsReqVO deliverGoodsReqVO) {
        return orderBaseService.deliverGoods(deliverGoodsReqVO);
    }

    /**
     * 获取订单状态的个数，包括待付款、待发货、待确认、待评价
     *
     * @return
     */
    @PostMapping("get_order_status_count")
    public JsonData getOrderStatusCount() {
        return orderBaseService.getOrderStatusCount();
    }
}

